package org.example;

import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-10-26
 * 13:37
 */
public class Test {
    public static void main(String[] args) {
        Stack stack=new Stack<Integer>();
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        String[] arr=s.split(" ");
        for (String ss:arr) {
            if(!operation(ss)){
                int val=Integer.parseInt(ss);
                stack.add(val);
            }else {
                int val2=(int)stack.pop();
                int val1=(int)stack.pop();
                switch(ss){
                    case "+":stack.add(val1+val2);
                    break;
                    case "-":stack.add(val1-val2);
                    break;
                    case "*":stack.add(val1*val2);
                }
            }
        }
        System.out.println(stack.peek());
    }
    public static boolean operation(String ss){
        if(ss.equals("+")||ss.equals("-")||ss.equals("*")||ss.equals("/")){
            return true;
        }else {
            return false;
        }
    }
}
